package com.my.biz.service.impl;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.my.biz.dao.ConfigMapper;
import com.my.biz.service.ISysConfigService;


 /**
 * 
 * @描述：系统配置 服务实现类
 * 
 * @创建人： ch
 * 
 * @创建时间：2017年05月04日 14:16:55
 * 
 */
@Service("sysConfigService")
public class SysConfigServiceImpl implements ISysConfigService{
	
	private static final Logger LOGGER = LoggerFactory.getLogger(SysConfigServiceImpl.class);

	@Autowired
	private ConfigMapper sysConfigMapper;
	
	@Override
	public String getStringValueByKey(String key) {
		return getValueByKey(key);
	}

	@Override
	public Boolean getBooleaValueByKey(String key) {
		String value = getValueByKey(key);
		return StringUtils.isBlank(value) ? Boolean.FALSE : Boolean.valueOf(value);
	}

	@Override
	public Integer getIntegerValueByKey(String key) {
		String value = getValueByKey(key);
		return StringUtils.isBlank(value) ? null : Integer.valueOf(value);
	}

	@Override
	public Long getLongValueByKey(String key) {
		String value = getValueByKey(key);
		return StringUtils.isBlank(value) ? null : Long.valueOf(value);
	}
	
	private String getValueByKey(String key){
		return sysConfigMapper.getSysConfigValueByCondition(key);
	}
	
}
